<div class="form-container">
<div class="validation-errors" id="validationErrors" style="display:none;"></div>
<?php
	Includes::IncludeFile( Includes::$FORM );
	Includes::IncludeFile( Includes::$SPACER );

	echo( form_open(base_url() . 'index.php/walk/walk_registration/step2_process/', array('id' => 'registrationForm') ) );

		echo('$20 -Individual registration');
		echo('<br />');
		echo('$40 - Family registration (more than one person)');

		Spacer::Render(0, 15);
		
		Form::OpenFormItem('Display name (for home page)*:', 260);
			echo( form_input(array('name'=>'displayName','id'=>'displayName','style'=>'width: 128px;')) );
		Form::CloseFormItem();
		Form::OpenFormItem('Number of walkers*:', 260);
			echo( form_input(array('name'=>'numWalkers','value'=>'0','id'=>'numWalkers','style'=>'width: 60px;')) );
		Form::CloseFormItem();
		Form::OpenFormItem('Number of runners*:', 260);
			echo( form_input(array('name'=>'numRunners','value'=>'0','id'=>'numRunners','style'=>'width: 60px;')) );
		Form::CloseFormItem();
		
		Spacer::Render(0, 15);
		
		Form::OpenFormItem('Number of additional T-Shirts (one included with registration) at $10 each:', 260);
			$additionalTShirtsOptions = array(''=>'None','1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9','10'=>'10');
			echo( form_dropdown('additionalTShirts', $additionalTShirtsOptions, '', 'id="additionalTShirts" style="width: 80px;" onchange="additionalTShirtChangeHandler();"') );
		Form::CloseFormItem();
		$tShirtSizeOptions = array(''=>'Select','S'=>'S','M'=>'M','L'=>'L','XL'=>'XL');
		Form::OpenFormItem('Size for included (free) T-Shirt*:', 260);
			echo( form_dropdown('includedTShirtSize', $tShirtSizeOptions, '', 'id="includedTShirtSize" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('<div id="atss1" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #1*:', 260);
			echo( form_dropdown('additionalTShirtSize1', $tShirtSizeOptions, '', 'id="additionalTShirtSize1" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss2" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #2*:', 260);
			echo( form_dropdown('additionalTShirtSize2', $tShirtSizeOptions, '', 'id="additionalTShirtSize2" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss3" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #3*:', 260);
			echo( form_dropdown('additionalTShirtSize3', $tShirtSizeOptions, '', 'id="additionalTShirtSize3" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss4" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #4*:', 260);
			echo( form_dropdown('additionalTShirtSize4', $tShirtSizeOptions, '', 'id="additionalTShirtSize4" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss5" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #5*:', 260);
			echo( form_dropdown('additionalTShirtSize5', $tShirtSizeOptions, '', 'id="additionalTShirtSize5" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss6" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #6*:', 260);
			echo( form_dropdown('additionalTShirtSize6', $tShirtSizeOptions, '', 'id="additionalTShirtSize6" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss7" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #7*:', 260);
			echo( form_dropdown('additionalTShirtSize7', $tShirtSizeOptions, '', 'id="additionalTShirtSize7" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss8" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #8*:', 260);
			echo( form_dropdown('additionalTShirtSize8', $tShirtSizeOptions, '', 'id="additionalTShirtSize8" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss9" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #9*:', 260);
			echo( form_dropdown('additionalTShirtSize9', $tShirtSizeOptions, '', 'id="additionalTShirtSize9" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		echo('<div id="atss10" style="display: none;">');
		Form::OpenFormItem('Size for extra T-Shirt #10*:', 260);
			echo( form_dropdown('additionalTShirtSize10', $tShirtSizeOptions, '', 'id="additionalTShirtSize10" style="width: 80px;" ') );
		Form::CloseFormItem();
		echo('</div>');
		
		Spacer::Render(0, 15);
		
		Form::OpenFormItem('My Funds Goal (put in a large amount to encourage sponsorship, you will not be charged):', 260);
			echo( form_input(array('name'=>'goal','id'=>'goal','style'=>'width: 60px;')) );
		Form::CloseFormItem();
		
		Form::OpenFormItem('Donation:', 260);
			echo( form_input(array('name'=>'donation','id'=>'donation','style'=>'width: 60px;')) );
		Form::CloseFormItem();

		$sourceOptions = array(''=>'Select','email'=>'email','friend'=>'friend','cmb'=>'cmb','other'=>'other');
		Form::OpenFormItem('Where did you hear about the event:', 260);
			echo( form_dropdown('hearAbout', $sourceOptions, '', 'id="hearAbout" style="width: 80px;" ') );
		Form::CloseFormItem();		
		
	echo( form_close() );
?>
	
	<div class="form-button-container">
		<?php if($this->config->item('debug')){ ?><a href="javascript: populate();">Populate</a><?php } ?>
		<a href="javascript: validate();"><img src="<?php echo( base_url() );?>assets/images/buttons/next_off.gif" border="0" onmouseover="this.src = '<?php echo( base_url() );?>assets/images/buttons/next_over.gif';" onmousedown="this.src = '<?php echo( base_url() );?>assets/images/buttons/next_on.gif';" onmouseup="this.src = '<?php echo( base_url() );?>assets/images/buttons/next_off.gif';" onmouseout="this.src = '<?php echo( base_url() );?>assets/images/buttons/next_off.gif';" /></a>
	</div>

</div>

<script type="text/javascript">
	function validate()
	{
		new Ajax.Request(baseUrl + 'index.php/validation/walk_registration_validation/validate_step2/', 
		{
			method:'post',
			parameters: Form.serialize( $('registrationForm') ),
		  	onSuccess: function(response)
			{
				var result = response.responseText;
				
				if( result == 'VALIDATION_SUCCESS' )
				{
					$('registrationForm').submit();
				}
				else
				{
					$('validationErrors').innerHTML = result;
					$('validationErrors').show();
					Effect.ScrollTo('validationErrors', { duration:'0.2', offset:-20 });
				}
			},
			onFailure: function(response){var result = response.responseText; $('validationErrors').innerHTML = result;
					$('validationErrors').show();alert('failed') }
		});
	}
	
	
	function additionalTShirtChangeHandler()
	{
		var additionalTShirtCount = $('additionalTShirts').options[$('additionalTShirts').selectedIndex].value;
		if(additionalTShirtCount == "")
		{
			additionalTShirtCount = 0;
		}
		
		for( var i = 1; i <= 10; i++ )
		{
			if( i <= additionalTShirtCount )
			{
				$('atss' + i).show();
			}
			else
			{
				$('atss' + i).hide();
			}
		}
	}
</script>

<?php if($this->config->item('debug')){ ?>
<script type="text/javascript">	
	function populate()
	{
		$('numWalkers').value = 3;
		$('numRunners').value = 2;
		$('additionalTShirts').selectedIndex = 3;
		$('includedTShirtSize').selectedIndex = 2;
		$('additionalTShirtSize1').selectedIndex = 3;
		$('additionalTShirtSize2').selectedIndex = 1;
		$('additionalTShirtSize3').selectedIndex = 4;
		$('goal').value = 250;
		$('donation').value = 35;
		$('hearAbout').selectedIndex = 2;
		
		additionalTShirtChangeHandler();
	}
</script>
<?php } ?>